<template>
  <div class="mod-config">
    <basic-container>
      <el-table :data="tableData" style="width: 40%;margin-top: 20px;" border v-loading="dataListLoading">
        <el-table-column prop="type" label="类型" header-align="center" align="center">
          <template slot-scope="scope">
                <el-input
                    placeholder="请输入内容"
                    v-model="scope.row.type"
                    @change="changVal(scope.row)">
                </el-input>
            </template>
        </el-table-column>
        <el-table-column prop="coefficient" label="系数" header-align="center" align="center">
            <template slot-scope="scope">
                <el-input-number
                    placeholder="请输入内容"
                    :precision="2"
                    v-model="scope.row.coefficient"
                    @change="changVal(scope.row)">
                </el-input-number>
            </template>
        </el-table-column>
      </el-table>
    </basic-container>
  </div>
</template>
<script>
import {getList,saveCoefficient} from '@/api/hetongrenwu/zhongdian/renyuanfenzu'
export default {
  data() {
    return {
        tableData:[],
        dataListLoading:false,
    };
  },
  created() {
      this.fnList()
  },
  methods: {
      fnList(){
        this.dataListLoading = true;
        getList().then(res=>{
            this.tableData = res.data.data;
            this.dataListLoading = false;
        })
      },
      changVal(item){
        if(item.type == ''){
          this.$message.warning("类型不能为空")
        }else{
          saveCoefficient(item).then(res=>{
              this.$message.success("修改成功");
              this.fnList();
          })
        }  
      }
  },
};
</script>
